Crate mutate_once

Source
Expand description

This library provides interior mutability that can be borrowed as plain immutable references &T in exchange for the write-once, read-many restriction.

Unlike std::cell::Cell or std::cell::RefCell, a plain immutable reference &T can be taken from MutOnce<T>. Once an immutable reference is taken, the value can never be mutated (even after all references are dropped).

The use cases include caching getter and delayed evaluation.

Structsยง

  • A mutable memory location that is write-once and can be borrowed as plain &T.
  • A wrapper type for a mutably borrowed value from a MutOnce<T>.